package com.tiantai.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tiantai.common.annotation.Log;
import com.tiantai.common.core.controller.BaseController;
import com.tiantai.common.core.domain.AjaxResult;
import com.tiantai.common.enums.BusinessType;
import com.tiantai.system.domain.TeaEnvAssessment;
import com.tiantai.system.service.ITeaEnvAssessmentService;
import com.tiantai.common.utils.poi.ExcelUtil;
import com.tiantai.common.core.page.TableDataInfo;

/**
 * 环境健康评估主Controller
 * 
 * @author ruoyi
 * @date 2025-03-21
 */
@RestController
@RequestMapping("/system/assessment")
public class TeaEnvAssessmentController extends BaseController
{
    @Autowired
    private ITeaEnvAssessmentService teaEnvAssessmentService;

    /**
     * 查询环境健康评估主列表
     */
    @PreAuthorize("@ss.hasPermi('system:assessment:list')")
    @GetMapping("/list")
    public TableDataInfo list(TeaEnvAssessment teaEnvAssessment)
    {
        startPage();
        List<TeaEnvAssessment> list = teaEnvAssessmentService.selectTeaEnvAssessmentList(teaEnvAssessment);
        return getDataTable(list);
    }

    /**
     * 导出环境健康评估主列表
     */
    @PreAuthorize("@ss.hasPermi('system:assessment:export')")
    @Log(title = "环境健康评估主", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TeaEnvAssessment teaEnvAssessment)
    {
        List<TeaEnvAssessment> list = teaEnvAssessmentService.selectTeaEnvAssessmentList(teaEnvAssessment);
        ExcelUtil<TeaEnvAssessment> util = new ExcelUtil<TeaEnvAssessment>(TeaEnvAssessment.class);
        util.exportExcel(response, list, "环境健康评估主数据");
    }

    /**
     * 获取环境健康评估主详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:assessment:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(teaEnvAssessmentService.selectTeaEnvAssessmentById(id));
    }

    /**
     * 新增环境健康评估主
     */
    @PreAuthorize("@ss.hasPermi('system:assessment:add')")
    @Log(title = "环境健康评估主", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TeaEnvAssessment teaEnvAssessment)
    {
        return toAjax(teaEnvAssessmentService.insertTeaEnvAssessment(teaEnvAssessment));
    }

    /**
     * 修改环境健康评估主
     */
    @PreAuthorize("@ss.hasPermi('system:assessment:edit')")
    @Log(title = "环境健康评估主", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TeaEnvAssessment teaEnvAssessment)
    {
        return toAjax(teaEnvAssessmentService.updateTeaEnvAssessment(teaEnvAssessment));
    }

    /**
     * 删除环境健康评估主
     */
    @PreAuthorize("@ss.hasPermi('system:assessment:remove')")
    @Log(title = "环境健康评估主", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(teaEnvAssessmentService.deleteTeaEnvAssessmentByIds(ids));
    }
}
